<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>Web浏览器控制方法 | Xuan的博客</title><meta name="author" content="Xuan"><meta name="copyright" content="Xuan"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="Web浏览器控制方法HTML介绍 标签：&lt;a&gt; 属性：href 类属性: class  12345678910&lt;!DOCTYPE html&gt;&lt;html&gt;  &lt;head&gt;    &lt;meta charset&#x3D;&quot;utf-8&quot;&gt;    &lt;title&gt;测试人论坛&lt;&#x2F;title&gt;  &lt;&#x2F;head&amp;gt">
<meta property="og:type" content="article">
<meta property="og:title" content="Web浏览器控制方法">
<meta property="og:url" content="http://leesmile.gitee.io/smile/2023/07/25/WebUI%E8%87%AA%E5%8A%A8%E5%8C%96/%E6%8E%A7%E4%BB%B6%E5%AE%9A%E4%BD%8D%E6%96%B9%E5%BC%8F/index.html">
<meta property="og:site_name" content="Xuan的博客">
<meta property="og:description" content="Web浏览器控制方法HTML介绍 标签：&lt;a&gt; 属性：href 类属性: class  12345678910&lt;!DOCTYPE html&gt;&lt;html&gt;  &lt;head&gt;    &lt;meta charset&#x3D;&quot;utf-8&quot;&gt;    &lt;title&gt;测试人论坛&lt;&#x2F;title&gt;  &lt;&#x2F;head&amp;gt">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gitee.com/leesmile/image-host/raw/master/images/202310271509357.jpg">
<meta property="article:published_time" content="2023-07-25T07:55:46.000Z">
<meta property="article:modified_time" content="2023-07-25T07:55:46.000Z">
<meta property="article:author" content="Xuan">
<meta property="article:tag" content="Selenium">
<meta property="article:tag" content="自动化测试">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gitee.com/leesmile/image-host/raw/master/images/202310271509357.jpg"><link rel="shortcut icon" href="/smile/img/favicon.png"><link rel="canonical" href="http://leesmile.gitee.io/smile/2023/07/25/WebUI%E8%87%AA%E5%8A%A8%E5%8C%96/%E6%8E%A7%E4%BB%B6%E5%AE%9A%E4%BD%8D%E6%96%B9%E5%BC%8F/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/smile/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = {
  root: '/smile/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'Web浏览器控制方法',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2023-07-25 15:55:46'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
    win.getCSS = (url,id = false) => new Promise((resolve, reject) => {
      const link = document.createElement('link')
      link.rel = 'stylesheet'
      link.href = url
      if (id) link.id = id
      link.onerror = reject
      link.onload = link.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        link.onload = link.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(link)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="/css/font.css" media="defer" onload="this.media='all'"><link rel="stylesheet" href="/css/custom.css" media="defer" onload="this.media='all'"><link rel="stylesheet" href="/css/whiteLine.css" media="defer" onload="this.media='all'"><link rel="stylesheet" href="/css/progress_bar.css" media="defer" onload="this.media='all'"><link rel="stylesheet" href="/css/cat.css"><link rel="stylesheet" href="/css/readPercent.css"><link rel="stylesheet" href="https://cdn1.tianli0.top/npm/element-ui@2.15.6/packages/theme-chalk/lib/index.css"><div id="myscoll"></div><!-- hexo injector head_end start --><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Zfour/Butterfly-double-row-display@1.00/cardlistpost.min.css"/>
<style>#recent-posts > .recent-post-item >.recent-post-info > .article-meta-wrap > .tags:before {content:"\A";
  white-space: pre;}#recent-posts > .recent-post-item >.recent-post-info > .article-meta-wrap > .tags > .article-meta__separator{display:none}</style>
<link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-footer-beautify@1.0.0/lib/runtime.css" media="print" onload="this.media='all'"><!-- hexo injector head_end end --><meta name="generator" content="Hexo 6.3.0"></head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://leesmile.gitee.io/smile/img/avatarImg.bmp" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/smile/archives/"><div class="headline">文章</div><div class="length-num">142</div></a><a href="/smile/tags/"><div class="headline">标签</div><div class="length-num">36</div></a><a href="/smile/categories/"><div class="headline">分类</div><div class="length-num">32</div></a></div><hr class="custom-hr"/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/smile/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/smile/archives/"><i class="fa-fw fas fa-archive"></i><span> 文章</span></a></div><div class="menus_item"><a class="site-page" href="/smile/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/smile/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://gitee.com/leesmile/image-host/raw/master/images/202310271509357.jpg')"><nav id="nav"><span id="blog-info"><a href="/smile/" title="Xuan的博客"><span class="site-name">Xuan的博客</span></a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/smile/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/smile/archives/"><i class="fa-fw fas fa-archive"></i><span> 文章</span></a></div><div class="menus_item"><a class="site-page" href="/smile/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/smile/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div></div><div id="nav-right"><a class="meihua faa-parent animated-hover" onclick="toggleWinbox()" title="美化设置-自定义你的风格" id="meihua-button"><svg class="faa-tada icon" style="height:26px;width:26px;fill:currentColor;position:relative;top:8px" aria-hidden="true"><use xlink:href="#icon-tupian1"></use></svg></a><a class="sun_moon faa-parent animated-hover" onclick="switchNightMode()" title="浅色和深色模式转换" id="nightmode-button"><svg class="faa-tada" style="height:25px;width:25px;fill:currentColor;position:relative;top:7px" viewBox="0 0 1024 1024"><use id="modeicon" xlink:href="#icon-moon"></use></svg></a></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">Web浏览器控制方法</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2023-07-25T07:55:46.000Z" title="发表于 2023-07-25 15:55:46">2023-07-25</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-07-25T07:55:46.000Z" title="更新于 2023-07-25 15:55:46">2023-07-25</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/smile/categories/%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95/">自动化测试</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/smile/categories/%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95/WebUI%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95/">WebUI自动化测试</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/smile/categories/%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95/WebUI%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95/Selenium/">Selenium</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="Web浏览器控制方法"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div><section class="main-hero-waves-area waves-area"><svg class="waves-svg" xmlns="http://www.w3.org/2000/svg" xlink="http://www.w3.org/1999/xlink" viewBox="0 24 150 28" preserveAspectRatio="none" shape-rendering="auto"><defs><path id="gentle-wave" d="M -160 44 c 30 0 58 -18 88 -18 s 58 18 88 18 s 58 -18 88 -18 s 58 18 88 18 v 44 h -352 Z"></path></defs><g class="parallax"><use href="#gentle-wave" x="48" y="0"></use><use href="#gentle-wave" x="48" y="3"></use><use href="#gentle-wave" x="48" y="5"></use><use href="#gentle-wave" x="48" y="7"></use></g></svg></section><div id="post-top-cover"><img class="nolazyload" id="post-top-bg" src="background-image: url('https://gitee.com/leesmile/image-host/raw/master/images/202310271509357.jpg')"></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="Web浏览器控制方法"><a href="#Web浏览器控制方法" class="headerlink" title="Web浏览器控制方法"></a>Web浏览器控制方法</h1><h4 id="HTML介绍"><a href="#HTML介绍" class="headerlink" title="HTML介绍"></a>HTML介绍</h4><ul>
<li>标签：<code>&lt;a&gt;</code></li>
<li>属性：href</li>
<li>类属性: class</li>
</ul>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE <span class="keyword">html</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">&quot;utf-8&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">title</span>&gt;</span>测试人论坛<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">&quot;https://ceshiren.com/&quot;</span> <span class="attr">class</span>=<span class="string">&quot;link&quot;</span>&gt;</span>链接<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br><span class="line">  <span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure>



<h4 id="Selenium的八大定位方式"><a href="#Selenium的八大定位方式" class="headerlink" title="Selenium的八大定位方式"></a>Selenium的八大定位方式</h4><p><a target="_blank" rel="noopener" href="https://www.selenium.dev/documentation/webdriver/elements/locators/">官方文档</a></p>
<table>
<thead>
<tr>
<th>Locator</th>
<th>Description</th>
</tr>
</thead>
<tbody><tr>
<td>class name</td>
<td>class 属性对应的值</td>
</tr>
<tr>
<td>css selector</td>
<td>css 表达式</td>
</tr>
<tr>
<td>id</td>
<td>id 属性对应的值</td>
</tr>
<tr>
<td>name</td>
<td>name 属性对应的值</td>
</tr>
<tr>
<td>link text</td>
<td>查找其可见文本与搜索值匹配的锚元素即为<code>&lt;a&gt;</code>标签</td>
</tr>
<tr>
<td>partial link text</td>
<td>查找其可见文本包含搜索值的锚元素。如果多个元素匹配，则只会选择第一个元素。</td>
</tr>
<tr>
<td>tag name</td>
<td>标签名称</td>
</tr>
<tr>
<td>xpath</td>
<td>xpath表达式</td>
</tr>
</tbody></table>
<h4 id="通过id定位"><a href="#通过id定位" class="headerlink" title="通过id定位"></a>通过id定位</h4><p>WebElement webElement &#x3D; driver.findElement(By.id(“ID属性对应的值”));</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Test</span></span><br><span class="line">    <span class="keyword">void</span> <span class="title function_">locatorByID</span><span class="params">()</span> &#123;</span><br><span class="line">        driver.get(<span class="string">&quot;https://ceshiren.com/&quot;</span>);</span><br><span class="line">        driver.findElement(By.id(<span class="string">&quot;site-logo&quot;</span>)).click();</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>



<h4 id="通过name定位"><a href="#通过name定位" class="headerlink" title="通过name定位"></a>通过name定位</h4><p>driver.find_element(By.NAME, “Name属性对应的值”)</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Test</span></span><br><span class="line">   <span class="keyword">void</span> <span class="title function_">locatorByName</span><span class="params">()</span> <span class="keyword">throws</span> InterruptedException &#123;</span><br><span class="line">       driver.get(<span class="string">&quot;http://www.baidu.com&quot;</span>);</span><br><span class="line">       driver.findElement(By.name(<span class="string">&quot;tj_briicon&quot;</span>)).click();</span><br><span class="line">       Thread.sleep(<span class="number">1000</span>);</span><br><span class="line">   &#125;</span><br></pre></td></tr></table></figure>



<h4 id="通过css表达式定位"><a href="#通过css表达式定位" class="headerlink" title="通过css表达式定位"></a>通过css表达式定位</h4><p>driver.findElement(By.cssSelector(“css表达式”));</p>
<p>可以在浏览器的console中验证</p>
<p>格式为$(“css表达式”)</p>
<table>
<thead>
<tr>
<th>类型</th>
<th>表达式</th>
</tr>
</thead>
<tbody><tr>
<td>标签</td>
<td>标签名</td>
</tr>
<tr>
<td>类</td>
<td>.class属性值</td>
</tr>
<tr>
<td>ID</td>
<td>#id属性值</td>
</tr>
<tr>
<td>属性</td>
<td>[属性名&#x3D;’属性值’]</td>
</tr>
</tbody></table>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//标签名</span></span><br><span class="line">$(<span class="string">&#x27;input&#x27;</span>)</span><br><span class="line"><span class="comment">//.类属性值</span></span><br><span class="line">$(<span class="string">&#x27;.s_ipt&#x27;</span>)</span><br><span class="line"><span class="comment">//#id属性值</span></span><br><span class="line">$(<span class="string">&#x27;#kw&#x27;</span>)</span><br><span class="line"><span class="comment">//[属性名=&#x27;属性值&#x27;]</span></span><br><span class="line">$(<span class="string">&#x27;[name=&quot;wd&quot;]&#x27;</span>)</span><br></pre></td></tr></table></figure>



<h4 id="CSS的关系定位"><a href="#CSS的关系定位" class="headerlink" title="CSS的关系定位"></a>CSS的关系定位</h4><table>
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody><tr>
<td>并集</td>
<td>元素,元素</td>
</tr>
<tr>
<td>邻近兄弟（了解即可）</td>
<td>元素+元素</td>
</tr>
<tr>
<td>兄弟（了解即可）</td>
<td>元素1~元素2</td>
</tr>
<tr>
<td>父子</td>
<td>元素&gt;元素</td>
</tr>
<tr>
<td>后代</td>
<td>元素 元素</td>
</tr>
</tbody></table>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//元素,元素</span></span><br><span class="line">$(<span class="string">&#x27;.bg,.s_ipt_wr,.new-pmd,.quickdelete-wrap&#x27;</span>)</span><br><span class="line"><span class="comment">//元素&gt;元素</span></span><br><span class="line">$(<span class="string">&#x27;#s_kw_wrap&gt;input&#x27;</span>)</span><br><span class="line"><span class="comment">//元素 元素</span></span><br><span class="line"><span class="comment">//被选中的 `input` 元素可以是 `id` 为 `form` 元素的直接子元素，也可以是更深层级的后代元素</span></span><br><span class="line">$(<span class="string">&#x27;#form input&#x27;</span>)</span><br><span class="line"><span class="comment">//元素+元素，了解即可</span></span><br><span class="line">$(<span class="string">&#x27;.soutu-btn+input&#x27;</span>)</span><br><span class="line"><span class="comment">//元素1~元素2，了解即可</span></span><br><span class="line">$(<span class="string">&#x27;.soutu-btn~i&#x27;</span>)</span><br></pre></td></tr></table></figure>



<h4 id="选择器和空格（后代选择器）区别"><a href="#选择器和空格（后代选择器）区别" class="headerlink" title="&gt; 选择器和空格（后代选择器）区别"></a><code>&gt;</code> 选择器和空格（后代选择器）区别</h4><p><code>&gt;</code> 选择器是用来选择直接子元素的</p>
<p>空格（后代选择器）用来选择后代元素，可以是更深层级的后代元素</p>
<h4 id="Css顺序关系"><a href="#Css顺序关系" class="headerlink" title="Css顺序关系"></a>Css顺序关系</h4><table>
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody><tr>
<td>父子关系+顺序</td>
<td>元素 元素</td>
</tr>
<tr>
<td>父子关系+标签类型+顺序</td>
<td>元素 元素</td>
</tr>
</tbody></table>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//:nth-child(n)，取id为from的子类中的第2个元素</span></span><br><span class="line">$(<span class="string">&#x27;#form&gt;input:nth-child(2)&#x27;</span>)</span><br><span class="line"><span class="comment">//:nth-of-type(n)，，取id为from的子类中的第2个input元素</span></span><br><span class="line">$(<span class="string">&#x27;#form&gt;input:nth-of-type(1)&#x27;</span>)</span><br></pre></td></tr></table></figure>



<h4 id="通过Xpath表达式定位"><a href="#通过Xpath表达式定位" class="headerlink" title="通过Xpath表达式定位"></a>通过Xpath表达式定位</h4><p>driver.findElement(By.xpath(“xpath表达式”));</p>
<p>在console中通过$x(“xpath表达式”)验证，或在elements中ctrl+f 输入xpath或者css</p>
<table>
<thead>
<tr>
<th>表达式</th>
<th>结果</th>
</tr>
</thead>
<tbody><tr>
<td>&#x2F;</td>
<td>从该节点的子元素选取</td>
</tr>
<tr>
<td>&#x2F;&#x2F;</td>
<td>从该节点的子孙元素选取</td>
</tr>
<tr>
<td>*</td>
<td>通配符</td>
</tr>
<tr>
<td>nodename</td>
<td>选取此节点的所有子节点</td>
</tr>
<tr>
<td>..</td>
<td>选取当前节点的父节点</td>
</tr>
<tr>
<td>@</td>
<td>选取属性</td>
</tr>
</tbody></table>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"># 整个页面</span><br><span class="line">$x(<span class="string">&quot;/&quot;</span>)</span><br><span class="line"># 页面中的所有的子元素</span><br><span class="line">$x(<span class="string">&quot;/*&quot;</span>)</span><br><span class="line"># 整个页面中的所有元素</span><br><span class="line">$x(<span class="string">&quot;//*&quot;</span>)</span><br><span class="line"># 查找页面上面所有的div标签节点</span><br><span class="line">$x(<span class="string">&quot;//div&quot;</span>)</span><br><span class="line"># 查找id属性为site-logo的节点</span><br><span class="line">$x(<span class="string">&#x27;//*[@id=&quot;site-logo&quot;]&#x27;</span>)</span><br><span class="line"># 查找节点的父节点</span><br><span class="line">$x(<span class="string">&#x27;//*[@id=&quot;site-logo&quot;]/..&#x27;</span>)</span><br></pre></td></tr></table></figure>



<h4 id="Xpath的索引"><a href="#Xpath的索引" class="headerlink" title="Xpath的索引"></a>Xpath的索引</h4><p>可以通过[i]获取第n个元素</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"># 获取此节点下的所有的li元素</span><br><span class="line">$x(<span class="string">&quot;//*[@id=&#x27;ember21&#x27;]//li&quot;</span>)</span><br><span class="line"># 获取此节点下【所有的节点的】第一个li元素</span><br><span class="line">$x(<span class="string">&quot;//*[@id=&#x27;ember21&#x27;]//li[1]&quot;</span>)</span><br></pre></td></tr></table></figure>



<h4 id="Xpath的高级表达式"><a href="#Xpath的高级表达式" class="headerlink" title="Xpath的高级表达式"></a>Xpath的高级表达式</h4><p>注意：所有的表达式需要和<code>[]</code>结合</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"># 选取最后一个input标签</span><br><span class="line"><span class="comment">//input[last()]</span></span><br><span class="line"># 选取属性name的值为passward并且属性pwd的值为<span class="number">123456</span>的input标签</span><br><span class="line"><span class="comment">//input[@name=&#x27;passward&#x27; and @pwd=&#x27;123456&#x27;]</span></span><br><span class="line"># 选取属性name的值为passward或属性pwd的值为<span class="number">123456</span>的input标签</span><br><span class="line"><span class="comment">//input[@name=&#x27;passward&#x27; or @pwd=&#x27;123456&#x27;]</span></span><br><span class="line"># 选取所有文本信息为<span class="string">&#x27;霍格沃兹测试开发&#x27;</span>的元素</span><br><span class="line"><span class="comment">//*[text()=&#x27;霍格沃兹测试开发&#x27;]</span></span><br><span class="line"># 选取所有文本信息包<span class="string">&#x27;霍格沃兹&#x27;</span>的元素</span><br><span class="line"><span class="comment">//*[contains(text(),&#x27;霍格沃兹&#x27;)]</span></span><br></pre></td></tr></table></figure>



<h4 id="通过link定位"><a href="#通过link定位" class="headerlink" title="通过link定位"></a>通过link定位</h4><p>driver.findElement(By.linkText(“链接的文本信息”))</p>
</article><div class="post-copyright"><div class="post-copyright__title"><span class="post-copyright-info"><h>Web浏览器控制方法</h></span></div><div class="post-copyright__type"><span class="post-copyright-info"><a href="http://leesmile.gitee.io/smile/2023/07/25/WebUI%E8%87%AA%E5%8A%A8%E5%8C%96/%E6%8E%A7%E4%BB%B6%E5%AE%9A%E4%BD%8D%E6%96%B9%E5%BC%8F/">http://leesmile.gitee.io/smile/2023/07/25/WebUI自动化/控件定位方式/</a></span></div><div class="post-copyright-m"><div class="post-copyright-m-info"><div class="post-copyright-a"><h>作者</h><div class="post-copyright-cc-info"><h>Xuan</h></div></div><div class="post-copyright-c"><h>发布于</h><div class="post-copyright-cc-info"><h>2023-07-25</h></div></div><div class="post-copyright-u"><h>更新于</h><div class="post-copyright-cc-info"><h>2023-07-25</h></div></div><div class="post-copyright-c"><h>许可协议</h><div class="post-copyright-cc-info"><a class="icon" rel="noopener" target="_blank" title="Creative Commons" href="https://creativecommons.org/"><i class="fab fa-creative-commons"></i></a><a rel="noopener" target="_blank" title="CC BY-NC-SA 4.0" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a></div></div></div></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/smile/tags/Selenium/">Selenium</a><a class="post-meta__tags" href="/smile/tags/%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95/">自动化测试</a></div><div class="post_share"><div class="social-share" data-image="https://gitee.com/leesmile/image-host/raw/master/images/202310271509357.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/smile/2023/07/25/WebUI%E8%87%AA%E5%8A%A8%E5%8C%96/%E6%8E%A7%E4%BB%B6%E4%BA%A4%E4%BA%92%E6%96%B9%E5%BC%8F/" title="控件交互方式"><img class="cover" src="https://gitee.com/leesmile/image-host/raw/master/images/202310271509357.jpg" onerror="onerror=null;src='/smile/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">控件交互方式</div></div></a></div><div class="next-post pull-right"><a href="/smile/2023/07/23/Java/JavaSE/%E9%87%8D%E5%85%A5%E9%94%81ReentrantLock/" title="重入锁ReentrantLock"><img class="cover" src="https://gitee.com/leesmile/image-host/raw/master/images/202310201611606.jpg" onerror="onerror=null;src='/smile/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">重入锁ReentrantLock</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/smile/2023/07/25/WebUI%E8%87%AA%E5%8A%A8%E5%8C%96/Selenium/" title="Selenium"><img class="cover" src="https://gitee.com/leesmile/image-host/raw/master/images/202310271509357.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-07-25</div><div class="title">Selenium</div></div></a></div><div><a href="/smile/2023/07/26/WebUI%E8%87%AA%E5%8A%A8%E5%8C%96/Cookie%E5%A4%8D%E7%94%A8/" title="Cookie复用"><img class="cover" src="https://gitee.com/leesmile/image-host/raw/master/images/202310271509357.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-07-26</div><div class="title">Cookie复用</div></div></a></div><div><a href="/smile/2023/07/25/WebUI%E8%87%AA%E5%8A%A8%E5%8C%96/%E5%85%83%E7%B4%A0%E7%AD%89%E5%BE%85%E6%96%B9%E5%BC%8F/" title="元素等待方式"><img class="cover" src="https://gitee.com/leesmile/image-host/raw/master/images/202310271509357.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-07-25</div><div class="title">元素等待方式</div></div></a></div><div><a href="/smile/2023/07/25/WebUI%E8%87%AA%E5%8A%A8%E5%8C%96/Web%E6%B5%8F%E8%A7%88%E5%99%A8%E6%8E%A7%E5%88%B6%E6%96%B9%E6%B3%95/" title="Web浏览器控制方法"><img class="cover" src="https://gitee.com/leesmile/image-host/raw/master/images/202310271509357.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-07-25</div><div class="title">Web浏览器控制方法</div></div></a></div><div><a href="/smile/2023/07/25/WebUI%E8%87%AA%E5%8A%A8%E5%8C%96/%E6%8E%A7%E4%BB%B6%E4%BA%A4%E4%BA%92%E6%96%B9%E5%BC%8F/" title="控件交互方式"><img class="cover" src="https://gitee.com/leesmile/image-host/raw/master/images/202310271509357.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-07-25</div><div class="title">控件交互方式</div></div></a></div><div><a href="/smile/2023/07/26/WebUI%E8%87%AA%E5%8A%A8%E5%8C%96/%E6%B5%8F%E8%A7%88%E5%99%A8%E5%A4%8D%E7%94%A8/" title="浏览器复用"><img class="cover" src="https://gitee.com/leesmile/image-host/raw/master/images/202310271509357.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-07-26</div><div class="title">浏览器复用</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="author_top is-center"><div class="avatar-img"><img src="https://leesmile.gitee.io/smile/img/avatarImg.bmp" onerror="this.onerror=null;this.src='/smile/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">Xuan</div><div class="author-info__description"></div></div><div class="card-info-data site-data is-center"><a href="/smile/archives/"><div class="headline">文章</div><div class="length-num">142</div></a><a href="/smile/tags/"><div class="headline">标签</div><div class="length-num">36</div></a><a href="/smile/categories/"><div class="headline">分类</div><div class="length-num">32</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/xxxxxx"><i class="fab fa-github"></i><span>Follow Me</span></a></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">This is my Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#Web%E6%B5%8F%E8%A7%88%E5%99%A8%E6%8E%A7%E5%88%B6%E6%96%B9%E6%B3%95"><span class="toc-number">1.</span> <span class="toc-text">Web浏览器控制方法</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#HTML%E4%BB%8B%E7%BB%8D"><span class="toc-number">1.0.0.1.</span> <span class="toc-text">HTML介绍</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#Selenium%E7%9A%84%E5%85%AB%E5%A4%A7%E5%AE%9A%E4%BD%8D%E6%96%B9%E5%BC%8F"><span class="toc-number">1.0.0.2.</span> <span class="toc-text">Selenium的八大定位方式</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E9%80%9A%E8%BF%87id%E5%AE%9A%E4%BD%8D"><span class="toc-number">1.0.0.3.</span> <span class="toc-text">通过id定位</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E9%80%9A%E8%BF%87name%E5%AE%9A%E4%BD%8D"><span class="toc-number">1.0.0.4.</span> <span class="toc-text">通过name定位</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E9%80%9A%E8%BF%87css%E8%A1%A8%E8%BE%BE%E5%BC%8F%E5%AE%9A%E4%BD%8D"><span class="toc-number">1.0.0.5.</span> <span class="toc-text">通过css表达式定位</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#CSS%E7%9A%84%E5%85%B3%E7%B3%BB%E5%AE%9A%E4%BD%8D"><span class="toc-number">1.0.0.6.</span> <span class="toc-text">CSS的关系定位</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E9%80%89%E6%8B%A9%E5%99%A8%E5%92%8C%E7%A9%BA%E6%A0%BC%EF%BC%88%E5%90%8E%E4%BB%A3%E9%80%89%E6%8B%A9%E5%99%A8%EF%BC%89%E5%8C%BA%E5%88%AB"><span class="toc-number">1.0.0.7.</span> <span class="toc-text">&gt; 选择器和空格（后代选择器）区别</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#Css%E9%A1%BA%E5%BA%8F%E5%85%B3%E7%B3%BB"><span class="toc-number">1.0.0.8.</span> <span class="toc-text">Css顺序关系</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E9%80%9A%E8%BF%87Xpath%E8%A1%A8%E8%BE%BE%E5%BC%8F%E5%AE%9A%E4%BD%8D"><span class="toc-number">1.0.0.9.</span> <span class="toc-text">通过Xpath表达式定位</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#Xpath%E7%9A%84%E7%B4%A2%E5%BC%95"><span class="toc-number">1.0.0.10.</span> <span class="toc-text">Xpath的索引</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#Xpath%E7%9A%84%E9%AB%98%E7%BA%A7%E8%A1%A8%E8%BE%BE%E5%BC%8F"><span class="toc-number">1.0.0.11.</span> <span class="toc-text">Xpath的高级表达式</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E9%80%9A%E8%BF%87link%E5%AE%9A%E4%BD%8D"><span class="toc-number">1.0.0.12.</span> <span class="toc-text">通过link定位</span></a></li></ol></li></ol></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/smile/2024/04/08/%E4%B8%8D%E5%90%8C%E8%A7%92%E5%BA%A6%E5%87%BA%E5%8F%91%E5%8E%BB%E9%9C%80%E6%B1%82%E6%B2%9F%E9%80%9A%E9%97%AE%E9%A2%98/" title="不同角度出发去需求沟通问题"><img src="https://gitee.com/leesmile/image-host/raw/master/images/202310271509358.jpg" onerror="this.onerror=null;this.src='/smile/img/404.jpg'" alt="不同角度出发去需求沟通问题"/></a><div class="content"><a class="title" href="/smile/2024/04/08/%E4%B8%8D%E5%90%8C%E8%A7%92%E5%BA%A6%E5%87%BA%E5%8F%91%E5%8E%BB%E9%9C%80%E6%B1%82%E6%B2%9F%E9%80%9A%E9%97%AE%E9%A2%98/" title="不同角度出发去需求沟通问题">不同角度出发去需求沟通问题</a><time datetime="2024-04-08T07:55:46.000Z" title="发表于 2024-04-08 15:55:46">2024-04-08</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/smile/2024/04/01/%E4%BA%A7%E5%93%81%E5%95%86%E4%B8%9A%E8%AE%A1%E5%88%92%E6%96%B9%E5%90%91%E6%80%9D%E8%80%83/" title="产品商业计划方向思考"><img src="https://gitee.com/leesmile/image-host/raw/master/images/202310271509358.jpg" onerror="this.onerror=null;this.src='/smile/img/404.jpg'" alt="产品商业计划方向思考"/></a><div class="content"><a class="title" href="/smile/2024/04/01/%E4%BA%A7%E5%93%81%E5%95%86%E4%B8%9A%E8%AE%A1%E5%88%92%E6%96%B9%E5%90%91%E6%80%9D%E8%80%83/" title="产品商业计划方向思考">产品商业计划方向思考</a><time datetime="2024-04-01T07:55:46.000Z" title="发表于 2024-04-01 15:55:46">2024-04-01</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/smile/2024/03/28/%E5%85%AC%E5%8F%B8%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95%E8%90%BD%E5%9C%B0%E7%9A%84%E9%9A%BE%E7%82%B9/" title="公司自动化测试落地的难点"><img src="https://gitee.com/leesmile/image-host/raw/master/images/202310271509358.jpg" onerror="this.onerror=null;this.src='/smile/img/404.jpg'" alt="公司自动化测试落地的难点"/></a><div class="content"><a class="title" href="/smile/2024/03/28/%E5%85%AC%E5%8F%B8%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95%E8%90%BD%E5%9C%B0%E7%9A%84%E9%9A%BE%E7%82%B9/" title="公司自动化测试落地的难点">公司自动化测试落地的难点</a><time datetime="2024-03-28T07:55:46.000Z" title="发表于 2024-03-28 15:55:46">2024-03-28</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/smile/2024/03/22/%E5%BC%82%E6%AD%A5%E4%BB%BB%E5%8A%A1%E7%9A%84%E5%85%B3%E9%94%AE%E5%9C%A8%E4%BA%A4%E4%BA%92%E8%AE%BE%E8%AE%A1/" title="异步任务的体验关键在交互设计"><img src="https://gitee.com/leesmile/image-host/raw/master/images/202310271509358.jpg" onerror="this.onerror=null;this.src='/smile/img/404.jpg'" alt="异步任务的体验关键在交互设计"/></a><div class="content"><a class="title" href="/smile/2024/03/22/%E5%BC%82%E6%AD%A5%E4%BB%BB%E5%8A%A1%E7%9A%84%E5%85%B3%E9%94%AE%E5%9C%A8%E4%BA%A4%E4%BA%92%E8%AE%BE%E8%AE%A1/" title="异步任务的体验关键在交互设计">异步任务的体验关键在交互设计</a><time datetime="2024-03-22T07:55:46.000Z" title="发表于 2024-03-22 15:55:46">2024-03-22</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/smile/2024/03/11/Git%E5%B7%A5%E4%BD%9C%E6%B5%81/" title="Git工作流"><img src="https://gitee.com/leesmile/image-host/raw/master/images/202310261354386.jpg" onerror="this.onerror=null;this.src='/smile/img/404.jpg'" alt="Git工作流"/></a><div class="content"><a class="title" href="/smile/2024/03/11/Git%E5%B7%A5%E4%BD%9C%E6%B5%81/" title="Git工作流">Git工作流</a><time datetime="2024-03-11T07:55:46.000Z" title="发表于 2024-03-11 15:55:46">2024-03-11</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2024 By Xuan</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i><span id="percent">0<span>%</span></span></button><button id="go-down" type="button" title="直达底部" onclick="btf.scrollToDest(document.body.scrollHeight, 500)"><i class="fas fa-arrow-down"></i></button></div></div><div><script src="/smile/js/utils.js"></script><script src="/smile/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.umd.min.js"></script><div class="js-pjax"></div><script async src="https://cdn1.tianli0.top/npm/vue@2.6.14/dist/vue.min.js"></script><script async src="https://cdn1.tianli0.top/npm/element-ui@2.15.6/lib/index.js"></script><script defer src="/js/cursor.js"></script><script async src="//npm.elemecdn.com/pace-js@1.2.4/pace.min.js"></script><script defer src="https://npm.elemecdn.com/jquery@latest/dist/jquery.min.js"></script><script defer data-pjax src="/js/cat.js"></script><script defer data-pjax src="/js/readPercent.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><!-- hexo injector body_end start --> <script data-pjax>if(document.getElementById('recent-posts') && (location.pathname ==='/'|| '/' ==='all')){
    var parent = document.getElementById('recent-posts');
    var child = '<div class="recent-post-item" style="width:100%;height: auto"><div id="catalog_magnet"><a class="magnet_link_more"  href="http://leesmile.gitee.io/smile/categories" style="flex:1;text-align: center;margin-bottom: 10px;">查看更多...</a></div></div>';
    console.log('已挂载magnet')
    parent.insertAdjacentHTML("afterbegin",child)}
     </script><style>#catalog_magnet{flex-wrap: wrap;display: flex;width:100%;justify-content:space-between;padding: 10px 10px 0 10px;align-content: flex-start;}.magnet_item{flex-basis: calc(50% - 5px);background: #87CEFA;margin-bottom: 10px;border-radius: 8px;transition: all 0.2s ease-in-out;}.magnet_item:hover{background: #00FFFF}.magnet_link_more{color:#555}.magnet_link{color:black}.magnet_link:hover{color:white}@media screen and (max-width: 600px) {.magnet_item {flex-basis: 100%;}}.magnet_link_context{display:flex;padding: 10px;font-size:16px;transition: all 0.2s ease-in-out;}.magnet_link_context:hover{padding: 10px 20px;}</style>
    <style></style><script data-pjax>
  function butterfly_footer_beautify_injector_config(){
    var parent_div_git = document.getElementById('footer-wrap');
    var item_html = '<div id="workboard"></div><p id="ghbdages"><a class="github-badge" target="_blank" href="https://hexo.io/" style="margin-inline:5px" data-title="博客框架为Hexo_v6.2.0" title=""><img src="https://img.shields.io/badge/Frame-Hexo-blue?style=flat&amp;logo=hexo" alt=""/></a><a class="github-badge" target="_blank" href="https://butterfly.js.org/" style="margin-inline:5px" data-title="主题版本Butterfly_v4.3.1" title=""><img src="https://img.shields.io/badge/Theme-Butterfly-6513df?style=flat&amp;logo=bitdefender" alt=""/></a><a class="github-badge" target="_blank" href="https://gitee.com/" style="margin-inline:5px" data-title="本站项目由Gitee托管" title=""><img src="https://img.shields.io/badge/Source-Github-d021d6?style=flat&amp;logo=GitHub" alt=""/></a><a class="github-badge" target="_blank" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" style="margin-inline:5px" data-title="本站采用知识共享署名-非商业性使用-相同方式共享4.0国际许可协议进行许可" title=""><img src="https://img.shields.io/badge/Copyright-BY--NC--SA%204.0-d42328?style=flat&amp;logo=Claris" alt=""/></a></p>';
    console.log('已挂载butterfly_footer_beautify')
    parent_div_git.insertAdjacentHTML("beforeend",item_html)
    }
  var elist = 'null'.split(',');
  var cpage = location.pathname;
  var epage = 'all';
  var flag = 0;

  for (var i=0;i<elist.length;i++){
    if (cpage.includes(elist[i])){
      flag++;
    }
  }

  if ((epage ==='all')&&(flag == 0)){
    butterfly_footer_beautify_injector_config();
  }
  else if (epage === cpage){
    butterfly_footer_beautify_injector_config();
  }
  </script><script async src="https://npm.elemecdn.com/hexo-butterfly-footer-beautify@1.0.0/lib/runtime.js"></script><!-- hexo injector body_end end --></body></html>